package thread;
//继承Thread 重写run 且使用匿名内部类(一次性类)
public class ThreadCreate3 {
    public static void main(String[] args) {
        Thread t = new Thread() {//匿名内部类 t指向的实例是Thread的子类
            @Override
            public void run() {
                while (true){
                    System.out.println("thread");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        };
        t.start();
        System.out.println("main");
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
}
